package com.macaline.util;

import java.util.Random;
import java.util.UUID;

import com.xnx3.DateUtil;
/**
 * 随机相关工具类
 * @author warm_joy
 */
public class RandomUtil {
	
	/**
	 * 获取32位的UUID
	 * @author warm_joy
	 * @param length 生成订单号的长度
	 * @return 订单号信息
	 */
	public static String getOrderNumber() {
		String uuid = UUID.randomUUID().toString().replaceAll("-", "");
		uuid = uuid.substring(13) + DateUtil.timeForUnix13();
		return uuid;
	}
	
	/**
	 * 获取用户注册时加密密码的随机盐值
	 * @author warm_joy
	 * @return 加密密码的随机盐值
	 */
	public static String getMD5RandomSalt() {
		String salt = "";
		Random random = new Random();
		for(int i = 0 ; i < 4 ; i++) {
			salt += random.nextInt(10);
		}
		return salt;
	}

}
